Designing complex interactive web applications generally requires some means for organizing the flow of pages that will be sent from a web server to a web client under particular conditions. Electronic commerce is one setting in which page flow organization is particularly important. A provider or operator of an online store may wish to structure the experiences of an online shopper who is browsing products, placing product items in a shopping cart, and ordering the items in a checkout phase.
Hypertext Transfer Protocol (HTTP) itself does not provide a suitable model for controlling page flow, as it is a stateless protocol in which the server acts by responding to incoming requests from the client. A traditional technique for describing page transitions in web applications is to model the application using a finite state machine. In accordance with such a model, a web application typically has multiple states and is in one state at a time. A transition to a new state may include sending a web page to the client browser. Finite state machines generally provide a scalable means for expressing page flow. However, state machine representations provide a low level of abstraction, tend to be unreadable for complex interactive applications, and are inconvenient to use and maintain.
An alternative approach to expressing page flows is to use a construct known as continuations. A continuation represents the future of a computation at a particular point in program execution. In the web server context, a continuation can be used to allow suspended processing to be restored after a client response is received. Continuations are generally convenient to use, enabling the complexities of page content flow to be modeled at a higher level of abstraction in a manner similar to a simple procedural program. However, in existing implementations of page flow description tools, continuations tend to be very expensive in consumption of computing resources, primarily because they make use of the underlying programming language to save and restore the state of the stack for the executing program.